package app.utils;

import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;

public class DateUtil {
    public static Date StringToDate(String dateStr,String pattern) throws Exception{
    	if(dateStr!=null&&!dateStr.equals("")){
    	   SimpleDateFormat sdf = new SimpleDateFormat(pattern);  
    	   Date date = sdf.parse(dateStr);
		   return date;
    	}
    	else
    		return null;
    }
    public static Date getNextDay(Date date) {  
        Calendar calendar = Calendar.getInstance();  
        calendar.setTime(date);  
        calendar.add(Calendar.DAY_OF_MONTH, +1);  
        date = calendar.getTime();  
        return date;  
    }  
    public static Date getPreDay(Date date,int i) {  
        Calendar calendar = Calendar.getInstance();  
        calendar.setTime(date);  
        calendar.add(Calendar.DAY_OF_MONTH, -i);  
        date = calendar.getTime();  
        return date;  
    }  
}
